	#include("/common/include/include.html")
<style>
	.breadcrumb li{
		float:left;
	}
</style>
<div class="admin-main">
	<blockquote class="layui-elem-quote">
					主页<span class="navi-xiegang">/</span>系统设置<span class="navi-xiegang">/</span>菜单管理  
					<div class="func-right">
						<a href="javascript:;" class="layui-btn layui-btn-small" id="add">
							<i class="layui-icon">&#xe608;</i> 添加菜单
						</a>
					</div>
	</blockquote>
	
	<div class="site-block-full" style="float: left;width: 200px;">
		<ul id="menuTree"></ul>
	</div>
	<div class="site-block-full" style="width: auto;margin-left: 260px;">
		<table class="site-table table-hover" lay-even>
			  <thead>
				    <tr><th style="width: 12px;padding-left: 15px;"><input type="checkbox" id="selected-all"></th><th>菜单名称</th><th>功能名称</th><th>对应URL</th><th>父级</th><th>排序</th><th>操作</th></tr> 
			  </thead>
			  <tbody id = "tableBody"></tbody>
		</table>           
		  <div id="pages" class = "pages"></div>
	</div>
</div>
		<!--模板-->
		<script type="text/html" id="conTemp">
				{{# layui.each(d.data, function(index, item){ }}
					<tr>
						<td><input type="checkbox" class="icheckbox_flat-green"></td>
						<td>{{ item.name?item.name:"" }}</td>
						<td>{{ item.age?item.age:"" }}</td>
						<td>{{ item.createtime?item.createtime:"" }}</td>
						<td>{{ item.createtime?item.createtime:"" }}</td>
						<td>{{ item.order }}</td>
						<td>
							<a href="/detail-1" target="_blank" class="layui-btn layui-btn-normal layui-btn-mini">预览</a>
							<a href="/manage/article_edit_1" class="layui-btn layui-btn-mini">编辑</a>
							<a href="javascript:;" data-id="1" data-opt="del" class="layui-btn layui-btn-danger layui-btn-mini">删除</a>
						</td>
					</tr>
				{{# }); }}
		</script>

<script>
layui.config({
	  base: ctx+'/common/js/'
}).use(['tree','ajax','paging'], function(){
		 ajax = layui.ajax;
		 tree = layui.tree;
		 paging = layui.paging();
		//初始化左侧菜单树
		var d = ajax.ajaxFunc(ctx+"/admin/menu/getAllMenuTree",null,"json",null);
		layui.tree({
		    elem: '#menuTree' //传入元素选择器
		    ,nodes: d.data
		    ,click: function(node){
		    	getPageData(node.id);
		    }  
		});
		//分页
		getPageData("");
		 
});

function getPageData(pid){
	paging.init({
		url: ctx+"/admin/menu/listData",  //地址
		elem: '#tableBody',
		tempElem: '#conTemp',  //模块容器
		pageConfig: {        //分页参数配置
			elem: '#pages',  //分页容器
			pageSize: 10,     //分页大小
			pid:pid
		},
		success:function(){   //渲染成功的回调
			//alert('渲染成功');
		},
		fail:function(msg){       //获取数据失败的回调
			//alert('获取数据失败')
		},
		complate:function(){     //完成的回调
			//alert('处理完成');
		}
	});
}


</script>